<?php
class CAdmin_crmentity extends CAdmin {
	function __construct(){
		parent::__construct();
		$this->check_crm_role();
	}
	
	/**
	 * 检查crmentity权限
	 */
	final private function check_crm_role(){
		if(in_array(ROUTE_A, array('edit'))){
			$operate_id = isset($_REQUEST[substr(ROUTE_C, 0,-6).'_id']) ? $_REQUEST[substr(ROUTE_C, 0,-6).'_id'] : $_POST['info'][substr(ROUTE_C, 0,-6).'_id'];
			$user_id = $_SESSION['userid'];
			$setype = ROUTE_C;
			$crmentitydb = new CrmEntity_Model();
//			print_r("crmid = $operate_id and (smcreatorid = '$user_id' or smsharerid ='$user_id') and setype = '$setype' and deleted = 0");
			$r = $crmentitydb->get_one("crmid = $operate_id and (smcreatorid = '$user_id' or smsharerid ='$user_id') and setype = '$setype' and deleted = 0");
			if(!$r) self::showmessage('您没有权限查看该信息!!');
		}
	}
}